import request from '@/utils/request'

// 获取地址列表
export const getAddressList = () => {
  return request.get('/address/list')
}

// 默认收货地址
export const setDefaultAddress = () => {
  return request.get('/address/defaultId')
}

// 获取收货地址详情
export const getAddressDetail = (addressId) => {
  return request.get('/address/detail', {
    params: {
      addressId
    }
  })
}

// 获取省市区地址
export const getProvinceCityArea = () => {
  return request.get('/region/tree')
}

// 添加收货地址
export const addAddress = (name, phone, detail) => {
  return request.post('/address/add', {
    form: {
      name,
      phone,
      region: [{ value: 782, label: '上海' }, { value: 783, label: '上海市' }, { value: 785, label: '徐汇区' }],
      detail
    }
  })
}

// 删除收货地址
export const delAddress = (addressId) => {
  return request.post('/address/remove', {
    addressId
  })
}
